package com.hr.剑指offer.work2.array;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：zhz
 * @date ：Created in 2020/12/08
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description: 三数之和
 **/
public class ThreeSum_3 {
    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> res=new ArrayList<>();
        List<Integer> list=null;
        for (int i = 0; i < nums.length-2; i++) {
            for (int j = i+1; j < nums.length-1; j++) {
                for (int k = 0; k < nums.length; k++) {
                    if (nums[i]+nums[j]+nums[k]==0){
                        list=new ArrayList<>();
                        list.add(i);
                        list.add(j);
                        list.add(k);
                        res.add(list);
                    }
                }
            }
        }
        return res;
    }
}
